
const now = new Date();
console.log(now); // 输出当前⽇期和时间

function Rectangle(name, width, height) {
    this.name = name; // 分配name属性
    this.width = width; // 分配width属性
    this.height = height; // 分配height属性
}

const rect1 = new Rectangle("矩形 1", 10, 10);
console.log(rect1);
// 输出：Rectangle { name: '矩形 1', width: 10, height: 10 }

const rect2 = Rectangle("矩形 2", 20, 20);
console.log(rect2); // 输出：undefined

function Rectangle(name, width, height) {
    this.name = name;
    this.width = width;
    this.height = height;
    this.area = function () {
        return this.width * this.height;
    };
}


const rect3 = new Rectangle("矩形 3", 10, 10);
console.log(rect3.area());// 输出：100
console.log(rect3.constructor);// 输出：[Function: Rectangle]

const rect4 = new Rectangle("矩形 4", 20, 10);
const rect5 = new Rectangle("矩形 5", 30, 30);
console.log(rect4.name);// 输出：矩形 4
console.log(rect5.area());// 输出：900

console.log(rect4 instanceof Rectangle);// 输出：true
console.log(rect5 instanceof Date);// 输出：false
